package com.ppc.controller.worker;

import com.ppc.result.PageResult;
import com.ppc.result.Result;
import com.ppc.service.WorkerComplaintService;
import com.ppc.vo.ComplaintDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 举报相关接口
 *
 * @author Jeferry
 * @date 2023/12/20
 */
@Slf4j
@RestController
@Api(tags = "工人举报接口")
public class WorkerComplaintController {

  @Autowired
  private WorkerComplaintService complaintService;

  /**
   * 创建举报
   *
   * @param requireId        需求id
   * @param complaintType   申诉类型
   * @return {@link Result}
   */
  @GetMapping("/worker/complaint")
  @ApiOperation("创建举报")
  public Result createComplaint(Long requireId, String complaintType) {   //调用service层来进行创建举报操作
    log.info("工人正在创建举报");
    complaintService.createComplaint(requireId, complaintType);
    return Result.success();
  }

  /**
   * 查询举报列表(根据状态)
   *
   * @param page           页码
   * @param pageSize       页大小
   * @param complaintStatus 举报状态
   * @return {@link Result}<{@link PageResult}>
   */
  @GetMapping("/worker/complaint/list")
  @ApiOperation("查询举报列表(根据状态)")
  public Result<PageResult> queryComplaintList(Integer page, Integer pageSize,
      Integer complaintStatus) {   //调用service层来进行查询举报列表操作
    log.info("工人正在查询举报列表:{}", complaintStatus);
    PageResult p = complaintService.queryComplaintList(page, pageSize, complaintStatus);
    return Result.success(p);
  }

  /**
   * 查看举报详情
   *
   * @param complaintId 举报id
   * @return {@link Result}<{@link ComplaintDetailVO}>
   */
  @GetMapping("/worker/complaint/detail")
  @ApiOperation("查看举报详情")
  public Result<ComplaintDetailVO> queryComplaintDetail(
      Long complaintId) {   //调用service层来进行查询举报详情操作
    log.info("工人正在查看举报详情");
    ComplaintDetailVO complaint = complaintService.queryComplaintDetail(complaintId);
    return Result.success(complaint);
  }
}
